<template>
  <div class="step3 l-form-list">
    <div class="form-blank-style">
      <mt-actionsheet :actions="actions"
                      v-model="chooseImgVisible"></mt-actionsheet>
      <selectFeel v-if="selectFeelVisible"
                  :selectFeelVisible="selectFeelVisible"
                  @selectFeelSubmit="getFeel"
                  :feelData="feeModelsObj"
                  :hasOpen="hasOpen"
                  :feeModels="initialData.feeModels"
                  :shopInfo="initialData"
                  :usablefeeList="usablefeeList"
                  @selectFeelBack="selectFeelBack" />
      <div class="ct ct-header">
        <div class="input-item-last ct-header">
          <div class="itemBox ct-header-list"
               @click="selectFeelShow">
            <div class="item item-common item-common-list">
              <div class="label required">支付方式</div>
              <div v-if="JSON.stringify(feeModelsObj) == '{}'"
                   class="pick-value select no-select">请选择</div>
              <i class="zhk-list_rarrow"></i>
            </div>
            <div class="item item-space"
                 v-for="(value,key) in feeModelsObj"
                 :key="key">
              <div class="label"
                   v-if="key =='01'">
                <i class="sl-zfbzf zfb-icon"></i>
              </div>
              <div class="label"
                   v-if="key =='02'">
                <i class="sl-wxzf wx-icon"></i>
              </div>
              <div class="label"
                   v-if="key =='03'">
                <i class="sl-ysf ysf-icon"></i>
              </div>
              <div class="label"
                   v-if="key =='04'">
                <i class="sl-ylzf yl-icon"></i>
              </div>
              <div class="pick-value select">
                <!-- <div>{{value[0].merchantTypeName}}</div> -->
                <div v-for="(item,index) in value"
                     :key="index">
                  <div v-if="item.useUnitPrice || item.unitPrice">
                    <p>{{'≤ '+item.unitPrice+' 元 '+repeatFeelData(item.feeValue)}}</p>
                    <p v-if="item.bankCardType ==1">{{'信用卡：> '+item.unitPrice+' 元 '+repeatFeelData(item.feeUpValue)}}</p>
                    <p v-if="item.bankCardType ==2">{{'储蓄卡：> '+item.unitPrice+' 元 '+repeatFeelData(item.feeUpValue)}}</p>
                    <p v-if="item.bankCardType ==2&&item.maxCharge>0">{{"储蓄卡手续费最高"+item.maxCharge+"元"}}</p>
                    <p v-if="item.bankCardType !=2&&item.bankCardType !=1">{{'> '+item.unitPrice+' 元 '+repeatFeelData(item.feeUpValue)}}</p>
                  </div>
                  <div v-else>
                    <p v-if="item.bankCardType ==1">{{'信用卡：'+repeatFeelData(item.feeValue)}}</p>
                    <p v-if="item.bankCardType ==2">{{'储蓄卡：'+repeatFeelData(item.feeValue)}}</p>
                    <p v-if="(item.bankCardType ==2&&item.maxCharge>0&&item.useUnitPrice) || (item.payType == '04'&&item.bankCardType ==2)">{{"储蓄卡手续费最高" + ((item.maxCharge == '不封顶' || item.maxCharge == undefined || String(item.maxCharge) == '0') ? '不封顶' : (item.maxCharge+"元"))}}</p>
                    <p v-if="item.bankCardType !=2&&item.bankCardType !=1">{{repeatFeelData(item.feeValue)}}</p>
                  </div>
                </div>
                <div v-if="value[0].encourageStatus != 0 ">{{value[0].encourageStatus == 1?'商户运营鼓励金':''}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="tt tt-body"
           v-if="this.initialData['businessLine']!=='1'">活动信息</div>
      <div class="ct ct-last ct-body"
           v-if="this.initialData['businessLine']!=='1'">
        <div class="upload-item ">
          <div class="item">
            <div class="item-tt">业务员门头合照</div>
            <div class="item-ct ">
              <div class="item-lft">
                <div class="warn-text">需要拍出完整门匾、门框（建议正对门店2米处拍摄）</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('需要拍出完整门匾、门框（建议正对门店2米处拍摄）','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/569251556267494.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgSalesmanLogo"
                     @click="chooseImg('yzImgSalesmanLogo')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgSalesmanLogo">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgSalesmanLogo,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgSalesmanLogo)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgSalesmanLogo')"></span>
                </div>
                <div class="unload">{{ additionalData.yzImgSalesmanLogo ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">业务员门店海报合照</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">需要拍出完整门匾、门框（建议正对门店2米处拍摄）</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('需要拍出完整门匾、门框（建议正对门店2米处拍摄）','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/876961556267478.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgSalesmanPoster"
                     @click="chooseImg('yzImgSalesmanPoster')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgSalesmanPoster">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgSalesmanPoster,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgSalesmanPoster)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgSalesmanPoster')"></span>
                </div>
                <div class="unload">{{ additionalData.yzImgSalesmanPoster ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">第三方平台截图</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">主流餐饮平台入驻商户展示页面，大众点评，美团，口碑，百度外卖，饿了么任选一个）</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('主流餐饮平台入驻商户展示页面，大众点评，美团，口碑，百度外卖，饿了么任选一个）','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/612291556267338.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzSettledPic"
                     @click="chooseImg('yzSettledPic')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzSettledPic">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzSettledPic,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzSettledPic)" />
                  <span class="sl-cwts"
                        @click="delImage('yzSettledPic')"></span>
                </div>
                <div class="unload">{{ additionalData.yzSettledPic ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">支付宝物料照</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">需露出完整收银台，带支付宝logo的收款码或扫码机具</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('需露出完整收银台，带支付宝logo的收款码或扫码机具','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/735731556267382.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgAlicashier"
                     @click="chooseImg('yzImgAlicashier')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgAlicashier">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgAlicashier,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgAlicashier)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgAlicashier')"></span>
                </div>
                <div class="unload">{{ additionalData.yzImgAlicashier ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">微信物料照</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">需露出完整收银台，带微信logo的收款码或扫码机具</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('需露出完整收银台，带微信logo的收款码或扫码机具','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/735731556267382.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgCashier"
                     @click="chooseImg('yzImgCashier')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgCashier">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgCashier,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgCashier)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgCashier')"></span>
                </div>
                <div class="unload">{{ additionalData.yzImgCashier ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">连锁门店证明</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">请注意证件上的文字能够清晰可见</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('请注意证件上的文字能够清晰可见','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/535901556267237.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgStandardProtocol"
                     @click="chooseImg('yzImgStandardProtocol')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgStandardProtocol">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgStandardProtocol,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgStandardProtocol)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgStandardProtocol')"></span>
                </div>
                 <div class="unload">{{ additionalData.yzImgStandardProtocol ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">承诺函</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">请注意证件上的文字能够清晰可见</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('请注意证件上的文字能够清晰可见','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/630671556267394.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzImgGreenAnnex"
                     @click="chooseImg('yzImgGreenAnnex')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzImgGreenAnnex">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzImgGreenAnnex,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzImgGreenAnnex)" />
                  <span class="sl-cwts"
                        @click="delImage('yzImgGreenAnnex')"></span>
                </div>
                <div class="unload">{{ additionalData.yzImgGreenAnnex ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">经营许可证照</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">请注意证件上的文字能够清晰可见</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('请注意证件上的文字能够清晰可见','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/757991556267310.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzBusinessLicense"
                     @click="chooseImg('yzBusinessLicense')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzBusinessLicense">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzBusinessLicense,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzBusinessLicense)" />
                  <span class="sl-cwts"
                        @click="delImage('yzBusinessLicense')"></span>
                </div>
                <div class="unload">{{ additionalData.yzBusinessLicense ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">食品经营许可证</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">请注意证件上的文字能够清晰可见</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('请注意证件上的文字能够清晰可见','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/241691556266620.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzBusinessLicenseFood"
                     @click="chooseImg('yzBusinessLicenseFood')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzBusinessLicenseFood">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzBusinessLicenseFood,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzBusinessLicenseFood)" />
                  <span class="sl-cwts"
                        @click="delImage('yzBusinessLicenseFood')"></span>
                </div>
                <div class="unload">{{ additionalData.yzBusinessLicenseFood ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="upload-item">
          <div class="item">
            <div class="item-tt">低费率证明</div>
            <div class="item-ct">
              <div class="item-lft">
                <div class="warn-text">请注意证件上的文字能够清晰可见</div>
                <div class="img-button">
                  <div class="look-img look-img1"
                       @click="()=>lookFigure('请注意证件上的文字能够清晰可见','https://jindd-prod-image.oss-cn-beijing.aliyuncs.com/2019/04/26/16/530181556267462.png')">查看示例图</div>
                </div>
              </div>
              <div class="item-rt">
                <div class="store-head-box border-dashed"
                     v-if="!additionalData.yzZeroRatesPhoto"
                     @click="chooseImg('yzZeroRatesPhoto')">
                  <img class="imgOpcity"
                       :src="require('../../assets/images/group.png')" />
                </div>
                <div class="store-head-box border-solid"
                     v-else-if="additionalData.yzZeroRatesPhoto">
                  <img :src="CommonUtil.imgUrlFormate(additionalData.yzZeroRatesPhoto,{w:'330',h:'206'})"
                       alt
                       @click="showImg(additionalData.yzZeroRatesPhoto)" />
                  <span class="sl-cwts"
                        @click="delImage('yzZeroRatesPhoto')"></span>
                </div>
                <div class="unload">{{ additionalData.yzZeroRatesPhoto ? '合照照片' : '上传照片' }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="sumbmit">
      <mt-button class="btn"
                 type="primary"
                 @click="submit">提交</mt-button>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Toast, MessageBox } from "mint-ui";
import jsBridge from "../../tools/jsBridge";
import inputClear from "../../components/inputClear/inputClear";
import selectFeel from "./selectFeel";
import moment from "moment";
export default {
  name: "openPaymentStep3",
  data() {
    return {
      CommonUtil: CommonUtil,
      //选择照片配置
      actions: [],
      chooseImgVisible: false,
      //选择费率
      selectFeelVisible: false,
      feelSelectOk: false,
      feeListFlag: false,
      feeListMsg: "",
      usablefeeList:'',
      //附加数据
      additionalData: {
        yzImgSalesmanLogo: "", //业务员门头合照
        yzImgSalesmanPoster: "", //业务员门店海报合照
        yzSettledPic: "", //入驻证明材料
        yzImgAlicashier: "", //支付宝支付物料照片
        yzImgCashier: "", //云纵微信支付物料照片
        yzImgStandardProtocol: "", //云纵商户总分店关系证明
        yzImgGreenAnnex: "", //绿洲活动补充材料
        yzBusinessLicense: "", //经营许可证
        yzBusinessLicenseFood: "", //食品经营许可证
        yzZeroRatesPhoto: "" //0费率证明
      },
      //费率数据
      feelData: {
        payType: "",
        merchantType: "",
        feeValue: "", //费率
        subsidyFee: "", //补贴后费率
        unitPrice: "",
        activityType: "",
        feeUpValue: "", //上行费率
        encourageStatus: 2, //是否开启商户运营鼓励金
        expiryTime: "", //费率截止时间
        merchantTypeName: "",
        remark: ""
      },
      feelInitialData: {},
      feeModelsObj:{},
      feeModels: ''
    };
  },
  props: {
    sumbmitData: Object,
    initialData: Object,
    editType: String,
    query: Object,
    hasOpen:Object
  },
  watch: {
    merchantDetail(newVal, oldVal) {
      if (JSON.stringify(newVal) != "{}") {
        //this.initialMerChantData(newVal);
      }
    },
    additionalData: {
      handler(val) {
        const backData = {
          additionalData: val
        };
        this.$emit("backDataModel", backData);
      },
      deep: true
    },
    feelData: {
      handler(val) {
        const backData = {
          feelData: val
        };
        this.$emit("backDataModel", backData);
      },
      deep: true
    }
  },
  computed: {
    merchantDetail() {
      return this.initialData;
    }
  },
  created() {
    if (!this.query["code"] && this.query["page"] != "ratesChangeApply") {
      this.getActivityType();
    }
  },
  mounted() {
    if (JSON.stringify(this.initialData) != "{}") {
      this.feeModels = this.initialData.feeModels;
      if(this.initialData.feeModels&&this.initialData.feeModels.length>0){
        this.initialData.channelType = this.initialData.feeModels[0].merchantType;
        this.initialData.openChannelType = this.initialData.feeModels[0].activityType;
      }
      let feeModelsObj = sessionStorage.getItem('feeModelsObj');
      if(this.query.rateToOpenPay && this.query["page"] != "ratesChangeApply"){
        feeModelsObj = JSON.parse(feeModelsObj);
        this.initialData.feeModels = feeModelsObj;
        this.initialData.channelType = feeModelsObj[0].merchantType;
        this.initialData.openChannelType = feeModelsObj[0].activityType;
      }
      this.initFeeModels(this.initialData.feeModels);
    }
  },
  methods: {
    initFeeModels(feeModels) {
      let feeModelsObj ={};
      for (let i = 0; i < feeModels.length; i++) {
        if(feeModels[i].merchantType!=3&&feeModels[i].merchantType!=4&&feeModels[i].merchantType!=11){
          if (feeModelsObj[feeModels[i].payType]) {
            feeModelsObj[feeModels[i].payType].push(feeModels[i]);
          } else {
            feeModelsObj[feeModels[i].payType] = [feeModels[i]];
          }
        }
      }
      this.feeModelsObj = feeModelsObj;

    },
    // merchantTypeName(merchantType) {
    //   if (merchantType == "2") {
    //     this.feelData.merchantTypeName = "网商";
    //   } else if (merchantType == "5") {
    //     this.feelData.merchantTypeName = "利楚";
    //   } else if (merchantType == "7") {
    //     this.feelData.merchantTypeName = "富友";
    //   } else if (merchantType == "8") {
    //     this.feelData.merchantTypeName = "乐刷";
    //   }
    // },
    repeatFeelData(data) {
      // if (data&&data.toString().length > 4) {
      //   return (data * 100).toFixed(2) + "%";
      // }
      return data + "%";
    },
    //初始化进件返回数据
    // initialMerChantData(data) {
    //   this.initFeeModels(this.initialData.feeModels);
    //   debugger
    //   this.feelInitialData = this.initialData;
    //   this.feelInitialData.merchantType = this.initialData.detailModel.merchantType;
    //   this.feelInitialData.accountType = this.initialData.bankcardModel.accountType;
    //   this.feelInitialData.settleAccountsType = this.initialData.bankcardModel.settleAccountsType;
    //   this.merchantTypeName(this.feelInitialData.feeModels[0].merchantType);
    //   if (this.query["code"]) {
    //     // 进件里的选择费率的某些参数因为和费率变更的参数类型，进制不同，需做转换
    //     //payType（01：支付宝 02：微信）
    //     if (this.query["payType"] == 2) {
    //       this.feelData.payType = "01";
    //     } else if (this.query["payType"] == 5) {
    //       this.feelData.payType = "02";
    //     }

    //     this.feelData.unitPrice = this.query["unitPrice4Apply"]; //笔单价
    //     this.feelData.feeUpValue = this.query["upFee4Apply"]
    //       ? (this.query["upFee4Apply"] / 100).toFixed(4)
    //       : "";
    //     this.feelData.merchantType = this.query["channelType4Apply"];
    //     this.feelData.activityType = this.query["openChannelType4Apply"];
    //     this.feelData.encourageStatus = this.query["encourageFee4ApplyStatus"];
    //     if (this.feelData.encourageStatus == 1) {
    //       this.feelData.subsidyFee = this.query["subsidyFee4Apply"]
    //         ? (this.query["subsidyFee4Apply"] / 100).toFixed(4)
    //         : "";
    //     }

    //     this.feelData.expiryTime = this.query["expireTime"] * 1000;
    //     this.feelData.remark = this.query["remark"];
    //     //pageActivityType活动类型 0-无活动 1-商户运营鼓励金 2-阶梯费率  ladderFlag是否是阶梯费率 0-不是 1-是
    //     //feeValue 当为阶梯费率时，此字段含义为下行费率,否则为申请费率
    //     if (this.feelInitialData.pageActivityType == 2) {
    //       this.feelInitialData.ladderFlag = 1;
    //       this.feelData.feeValue = this.query["downFee4Apply"]
    //         ? (this.query["downFee4Apply"] / 100).toFixed(4)
    //         : "";
    //     } else {
    //       this.feelInitialData.ladderFlag = 0;
    //       this.feelData.feeValue = this.query["applyFee"]
    //         ? (this.query["applyFee"] / 100).toFixed(4)
    //         : "";
    //     }
    //   }
    //   this.merchantTypeName(this.feelData.merchantType);
    // },
    //选择图片的方式本地相册或者拍照,如果传ocr需要进行ocr图像识别
    repeatImgUrl(url, resize) {
      if (resize) {
        return CommonUtil.getThumbnail(url);
      }
      return CommonUtil.getThumbnail(url);
    },
    chooseImg: function(type, ocr) {
      var _this = this;
      _this.actions = [
        {
          name: "拍照",
          method: function() {
            jsBridge.selectPicture(
              {
                options: "拍照",
                noCrop: true,
                compress: { sizeLimit: "1", unit: "M" }
              },
              function(result) {
                _this.doUploadPic(type, result, ocr);
              },
              function(result) {
              }
            );
          }
        },
        {
          name: "选择图片",
          method: function() {
            jsBridge.selectPicture(
              {
                options: "选择图片",
                noCrop: true,
                compress: { sizeLimit: "1", unit: "M" }
              },
              function(result) {
                _this.doUploadPic(type, result, ocr);
              },
              function(result) {
              }
            );
          }
        }
      ];

      this.chooseImgVisible = true;
      return false;
    },
    //删除图片
    delImage(key) {
      this.additionalData[key] = "";
    },
    lookFigure(text, imgUrl) {
      MessageBox.close(false);
      MessageBox({
        title: "",
        message: `<div class='figureImg'><img src="${imgUrl}" /></div><div class='figureText'><p>${text}</p></div>`,
        confirmButtonText: "知道了",
        closeOnClickModal: false
      });
    },
    showImg: function(url) {
      let urlArr = [];
      // urlArr.push(this.repeatImgUrl(url));
      urlArr.push(CommonUtil.imgUrlFormate(url));
      try {
        jsBridge.viewPicture({ files: urlArr }, function(params) {
        });
      } catch (e) {
        Toast("预览失败");
      }
    },
    //上传图片到服务器
    doUploadPic: function(type, result, ocr) {
      var url = "image/upload.do";
      let params = {};

      jsBridge.doUploadPic(
        {
          url: url,
          file: result.resultObject,
          data: params,
          //限制图片压缩后的大小最大1.2M
          compress: { sizeLimit: "1", unit: "M" }
        },
        result => {
          //以下为正常的业务逻辑
          if (result && result.success) {
            var uploadResult =
              result.resultObject.imageUrl || result.resultObject;
            if (uploadResult) {
              var url = uploadResult;
              this.additionalData[type] = url;
            }
            return;
          }
          var msg = result.msg || "上传失败";
          Toast(msg);
        },
        function(result) {

        }
      );
    },
    changeMoment(date) {
      return moment(date).format("YYYY-MM-DD");
    },
    selectFeelShow() {
      // if (this.feeListFlag) {
      //   MessageBox.close(false);
      //   MessageBox.alert(this.feeListMsg).then(action => {});
      //   return;
      // }
      //补充进件不能修改费率信息
      if(this.query['rateToOpenPay']){
        return
      };
      if(this.initialData['isEntryStatus'] == '1'){
        return;
      }
      this.feelSelectOk = true;
      this.selectFeelVisible = true;
      this.$emit("modelRturn", true);
      //$('.main-page-body').scrollTop(0);
      $(".mint-popup-right").css({ position: "absolute" });
      $(".main-page-body").css({ "overflow-y": "hidden", position: "static" });
    },
    selectFeelBack() {
      this.selectFeelVisible = false;
      this.$emit("modelRturn", false);
      $(".mint-popup-right").css({ position: "fixed" });
      $(".main-page-body").css({ "overflow-y": "auto", position: "relative" });
    },
    //获取费率
    getFeel(params) {
      let temp= JSON.parse(params);
      this.selectFeelVisible = false;
      this.$emit("modelRturn", false);
      $(".mint-popup-right").css({ position: "fixed" });
      $(".main-page-body").css({ "overflow-y": "auto", position: "relative" });
      this.initialData.feeModels = temp.feeModels;
      this.initialData.channelType = temp.channelType;
      this.initialData.channelTypeName = temp.channelTypeName;
      this.initialData.openChannelType = temp.openChannelType;
      this.initialData.openChannelTypeName = temp.openChannelTypeName;
      this.initialData.isManualSelection = temp.isManualSelection;
      this.initialData.remark = temp.remark;
      this.initFeeModels(temp.feeModels);
    },
    //查询活动状态
    async getActivityType() {
      const params = {
        type: "get",
        url:
          "/merchant/fee/query/usablefee.do?supplierId=" +
          this.initialData.supplierId +
          "&shopId=" +
          this.initialData.shopId +
          "&merchantType=" +
          this.initialData.detailModel.merchantType+"&scenario=1",
        controlLoading: true
      };
      var response = await this.ajax(params);
      if (response.success) {
        this.feeListFlag = false;

        if (response.resultObject.length > 0) {
          for (let i = 0; i < response.resultObject.length; i++) {
            let element = response.resultObject[i];
            if (element.payType == '04') {
              let depositCardServiceChargeList = element.feeInfo[0].depositCardServiceChargeList;
              if (depositCardServiceChargeList) {
                element.feeInfo[0].depositCardServiceChargeList.push('不封顶');
                break;
              }
            }
          }
        }

        this.usablefeeList = response.resultObject;
        // const res = response.resultObject;
        // this.feelInitialData.supplierId = this.initialData.supplierId;
        // this.feelInitialData.shopId = this.initialData.shopId;
        // this.feelInitialData.payType = 0;
        // this.feelInitialData.pageActivityType = res.pageActivityType;
        // this.feelInitialData.feeInfo = res.feeInfo;
        //   "pageActivityType111",
        //   this.feelInitialData.pageActivityType
        // );
      } else {
        this.feeListMsg = response.msg;
        this.feeListFlag = true;
        Toast(this.feeListMsg||"获取费率失败");
      }
    },
    checkData(fieldName) {
      if (!this.initialData.feeModels||this.initialData.feeModels.length==0) {
        Toast("请选择费率");
        return false;
      }
      /* if(!this.initialData.channelType||!this.initialData.openChannelType){
        Toast("请选择通道");
        return false;
      } */
      return true;
    },
    repeatDate(data) {
      //时间转成13位时间戳
      if (data.detailModel.legalIdnumExpireStart) {
        data.detailModel.legalIdnumExpireStart = moment(
          data.detailModel.legalIdnumExpireStart
        )
          .endOf("d")
          .valueOf();
      }
      if (data.detailModel.licenseExpireStart) {
        data.detailModel.licenseExpireStart = moment(
          data.detailModel.licenseExpireStart
        )
          .endOf("d")
          .valueOf();
      }
      if (data.bankcardModel.merchantIdExpireStart) {
        data.bankcardModel.merchantIdExpireStart = moment(
          data.bankcardModel.merchantIdExpireStart
        )
          .endOf("d")
          .valueOf();
      }
      // if (data.feeModels && data.feeModels.length > 0) {
      //   data.feeModels.map(item => {
      //     if (item.feeValue.toString().length <= 4) {
      //       item.feeValue = (Number(item.feeValue) / 100).toPrecision(2);
      //     }
      //     if (this.feelData.encourageStatus == "1") {
      //       if (item.subsidyFee.toString().length <= 4) {
      //         item.subsidyFee = (Number(item.subsidyFee) / 100).toPrecision(2);
      //       }
      //     }
      //   });
      // }
      if (data.detailModel.merchantType == "01") {
        // data.detailModel.merchantCompany = "个体户" + data.detailModel.principalPerson;
        data.detailModel.merchantCompany = "商户" + data.detailModel.principalPerson;
      }
      // 不封顶费率改为80上传
      for (let i = 0; i < data.feeModels.length; i++) {
        let element = data.feeModels[i];
        if (element.payType == '04' && element.maxCharge == '不封顶') {
          element.maxCharge = '999999';
          break;
        }
      }
    },
    //提交
    submit() {
      if (this.isLoadding) {
        return;
      }
      {
        if (!this.checkData()) {
          return;
        } else {
          let url = '/merchant/info/commit/first/entry.do';
          if (this.query["code"] || this.query["page"] == "ratesChangeApply") {
            this.isLoadding = true;
            const sumbmitData = Object.assign({}, this.initialData);
            this.repeatDate(sumbmitData);
            //补充进件提交接口
            if(this.query.rateToOpenPay){
              url = '/merchant/info/commit/supply/entry.do';
              //开通其他支付方式引起的补充进件
              if(this.query.rateToOpenPayType == 'openPay'){
                sumbmitData.scenario = 1;
              };
              //变更费率引起的补充进件
              if(this.query.rateToOpenPayType == 'changeFee'){
                sumbmitData.scenario = 0;
              };
            };
            this.ajax({
              type: "post",
              data: sumbmitData,
              url: url, //补充资料提交接口
              controlLoading: true
            })
              .then(response => {
                this.isLoadding = false;
                if (response.success) {
                  Toast({
                    message: "提交成功",
                    iconClass: "toast-icon sl-czcg"
                  });
                  if (this.query["code"]) {
                    this.$router.replace({ path: "/operation/storeList" });
                  } else if (this.query["page"] == "ratesChangeApply") {
                    this.$router.replace({
                      path: "/operation/ratesChangeApply",
                      query: { tabId: "2" }
                    });
                  }
                } else {
                  Toast(response.msg);
                }
              })
              .catch(error => {
                this.isLoadding = false;
              });
          } else {
            this.isLoadding = true;
            // const feelData1 = Object.assign({}, this.feelData);
            // feelData1.payType = "01";
            // const feelData2 = Object.assign({}, this.feelData);
            // feelData2.payType = "02";
            // debugger
            // this.initialData.feeModels = [feelData1, feelData2];
            const sumbmitData = Object.assign({}, this.initialData);
            this.repeatDate(sumbmitData);
            // sumbmitData.detailModel.principalCertType = "01";
            // sumbmitData.feeInfo = [];
            this.ajax({
              type: "post",
              url: url,
              data: sumbmitData,
              controlLoading: true
            })
              .then(response => {
                this.isLoadding = false;
                if (response && response.success) {
                  MessageBox.close(false);
                  MessageBox({
                    title: "",
                    message:
                      "<div class='result' style='text-align:center'><i class='sl-czcg common-dialog-tip-icon blue'></i><p>" +
                      response.msg +
                      "</p></div>",
                    showCancelButton: true,
                    cancelButtonText: "完成",
                    showConfirmButton: true,
                    confirmButtonText: "查看开通支付申请",
                    closeOnClickModal: false
                  }).then(action => {
                    if (response.resultObject == "ING") {
                      //审批中（开通支付申请列表tab项状态）
                      this.$router.replace({
                        path: "/operation/openPayApply",
                        query: { tabId: "1" }
                      });
                    } else if (response.resultObject == "WAIT") {
                      //确认中
                      this.$router.replace({
                        path: "/operation/openPayApply",
                        query: { tabId: "2" }
                      });
                    } else {
                      this.$router.replace({
                        path: "/operation/openPayApply",
                        query: { tabId: "1" }
                      });
                    }
                  });
                } else {
                  if (response.code == "1000000096") {
                    MessageBox.close(false);
                    MessageBox.alert(
                      '<div style="text-align:center">该门店在黑名单，无法操作</div>'
                    );
                    return;
                  }
                  Toast(response.msg);
                }
              })
              .catch(error => {
                this.isLoadding = false;
              });
          }
        }
      }
    }
  },
  computed: {},
  components: {
    inputClear,
    selectFeel
  }
};
</script>
<style lang='scss' scoped>
@import "openPayment";
@import './openPay.scss';
</style>
<style lang='scss' scoped>
@import '../../style/public';
.upload-item{
  margin-bottom: pw(15);
}
</style>
